package melwi;



import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Komp implements Comparator{
public int compare(Object o1, Object o2){
	if(o1 instanceof Hmat && o2 instanceof Hmat){
	Hmat h1=(Hmat)o1; 
	Hmat h2=(Hmat)o2;
	if (h1.getMin()>h2.getMin()){return 1;}
	else {
		if(h1.getMin()<h2.getMin()){return -1;}
		else{
			for(int i=0; i<h1.getPoloha().length; i++){
				if(h1.getPoloha()[i]>h2.getPoloha()[i]){
					return 1;
				}else{
				if(h1.getPoloha()[i]<h2.getPoloha()[i]){
					return -1;
				}
				}
			}
		}
	}
	return 0;
	}
	else{
		throw new ClassCastException("Nelze porovnat nic jineho nez Hmat");
	}
}
}
